#include <stdio.h>
#define maxn 5005
int n, m;
struct candidate {
  int id, grade;
}C[maxn];
int comp(struct candidate a, struct candidate b) {
  if(a.grade==b.grade)return a.id<b.id;
  return a.grade>b.grade;
}
void swap(struct candidate a[], int i, int j) {
  struct candidate t=a[i];
  a[i]=a[j];
  a[j]=t;
}
void sort(struct candidate a[], int n) {
  if(n<=1) return;
  int l=0, r=n;
  int pivotIndex = (l+r)/2;
  struct candidate pivot = a[pivotIndex];
  swap(a, 0, pivotIndex);
  while(l<r) {
    while(l<r&&!comp(a[--r], pivot));
    while(l<r&&!comp(pivot, a[++l]));
    swap(a, l, r);
  }
  swap(a, 0, l);
  sort(a, l);
  sort(a+l+1, n-l-1);
}
void show() {
  int m150 = m + m/2 - 1;
  int gradeline = C[m150].grade;
  printf("%d ", gradeline);
  while(C[m150].grade == C[m150+1].grade) m150++;
  printf("%d\n", m150+1);
  for(int i=0; i<=m150; ++i) {
    printf("%d %d\n", C[i].id, C[i].grade);
  }
}
int main() {
  scanf("%d%d", &n, &m);
  for(int i=0; i<n; ++i)
    scanf("%d%d", &C[i].id, &C[i].grade);
  sort(C, n);
  show();
}
